//议和Layer

var summationMenu = {
	_label : null,
	
	_menu : null,
	
	ShowUI : function(playername){
		summationMenu._label = cc.LabelTTF.create(
				"敌军[" + playername + "]向我军议和\n\n(此时议和，则战役结果为：胜利，分数：50000)",
				"simhei", 45);
		campaignScene.canvaslayer.addChild(summationMenu._label);
		
		var menuAgree = summationMenu._CreateNormalButton("同意",summationMenu._OnAgree);
		var menuRefuse = summationMenu._CreateNormalButton("拒绝",summationMenu._OnRefuse);
		summationMenu._menu = cc.Menu.create(menuAgree, menuRefuse)
		summationMenu._menu.attr({x : 0, y : 0});
		campaignScene.canvaslayer.addChild(summationMenu._menu);
		
		var winSize = cc.director.getWinSize();
		ArrangeVertical(winSize.width * 0.5, winSize.height * 0.5, winSize.height * 0.15,
				[summationMenu._label, menuAgree]);
		ArrangeHorizontal(menuAgree.x, menuAgree.y, winSize.width * 0.15, [menuAgree, menuRefuse]);
	},
	
	HideUI : function(){
		if (summationMenu._menu != null){
			summationMenu._menu.removeFromParent();
			summationMenu._menu = null;
		}
		if (summationMenu._label != null){
			summationMenu._label.removeFromParent();
			summationMenu._label = null;
		}
	},
	
	OnAgreeSummation : null,
	_OnAgree : function(sender){
		summationMenu.HideUI();
		if (summationMenu.OnAgreeSummation != null)
			summationMenu.OnAgreeSummation();
	},
	
	OnRefuseSummation : null,
	_OnRefuse : function(sender){
		summationMenu.HideUI();
		if (summationMenu.OnRefuseSummation != null)
			summationMenu.OnRefuseSummation();
	},

	_CreateNormalButton : function(text,callback){
		var button = new cc.MenuItemImage(resource.ctrlbtnNormal_png,resource.ctrlbtnDown_png, resource.ctrlbtnDisable_png, callback, this);
		var label = cc.LabelTTF.create(text, "simhei", 28);
		label.setPosition(button.width * 0.5, button.height * 0.5);
		label.setColor(cc.color(0,0,0));
		button.addChild(label);
		return button;
	}
};